//
//  YTAuthorInfoHeaderView.m
//  yitaicaijing
//
//  Created by DIANGHONG on 2018/9/17.
//  Copyright © 2018年 DIANGHONG. All rights reserved.
//

#import "YTAuthorInfoHeaderView.h"
@interface YTAuthorInfoHeaderView ()
@property (weak, nonatomic) IBOutlet UIImageView *iconImgView;
@property (weak, nonatomic) IBOutlet UILabel *authorNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *authorDesLabel;
@property (weak, nonatomic) IBOutlet UILabel *fansNumLabel;
@property (weak, nonatomic) IBOutlet UILabel *articleNumLabel;
@property (weak, nonatomic) IBOutlet UILabel *lookNumLabel;
@property (weak, nonatomic) IBOutlet UIButton *followButton;

@end
@implementation YTAuthorInfoHeaderView
- (IBAction)followButtonClick:(UIButton *)sender
{
    NSAssert(self.followButtonClick != nil, @"followButtonClick 不能为nil");
    self.followButtonClick(self.authorInfo.ID,self.authorInfo.is_follow.boolValue);
}

+ (instancetype)headerView
{
    UINib *nib = [UINib nibWithNibName:@"YTAuthorInfoHeaderView" bundle:nil];
    YTAuthorInfoHeaderView *headerView = [nib instantiateWithOwner:nil options:nil][0];
    return headerView;
}
- (void)awakeFromNib
{
    [super awakeFromNib];
    
    self.iconImgView.layer.masksToBounds = YES;
    self.iconImgView.layer.cornerRadius = self.iconImgView.bounds.size.width / 2;
}
- (void)setAuthorInfo:(YTAuthorInfo *)authorInfo
{
    _authorInfo = authorInfo;
    
    [self.iconImgView sd_setImageWithURL:[NSURL URLWithString:authorInfo.user_avatar]];
    self.authorNameLabel.text = authorInfo.display_name;
    self.authorDesLabel.text = authorInfo.user_description;
    self.fansNumLabel.text = authorInfo.follow_num;
    self.articleNumLabel.text = authorInfo.article_total;
    self.lookNumLabel.text = authorInfo.views_total;
    
    self.followButton.selected = authorInfo.is_follow.boolValue;
}



@end
